package com.ddone.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ddone.model.auth.SysLoginLog;
import com.ddone.model.vo.Result;
import com.ddone.model.vo.SysLoginLogQueryVo;
import com.ddone.service.SysLoginLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ddone
 * @date 2024/4/2-10:26
 */
@RestController
@Api(tags = {"登录日志API"})
@RequestMapping("sys-login-log")
public class SysLoginLogController {

    @Autowired
    private SysLoginLogService sysLoginLogService;


    @PreAuthorize("hasAuthority('bnt.sysLoginLog.list')")
    @ApiOperation("获取登录日志分页列表")
    @GetMapping("/{page}/{size}")
    public Result<Object> page(
            @ApiParam(name = "page",value = "当前页码",required = true)
            @PathVariable Long page,
            @ApiParam(name="size",value = "每页显示的记录数",required = true)
            @PathVariable Long size,
            @ApiParam(name="sysLoginLogQueryVo", value = "查询条件",required = false)
            SysLoginLogQueryVo sysLoginLogQueryVo){
        Page<SysLoginLog> pageParam = new Page<>(page, size);
        IPage<SysLoginLog> pageResult = sysLoginLogService.findPage(pageParam, sysLoginLogQueryVo);
        return Result.ok(pageResult);
    }
}
